package com.cloud.provider;

import com.cloud.provider.client.IFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class HelloController {

    @Value("${server.port}")
    private String port;

    @Autowired
    IFeignClient iFeignClient;

    @GetMapping("/hello")
    public String sayHello(@RequestParam("name") String name){
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return name+" from "+port;
    }

    @GetMapping("/test")
    public String test(){
        return iFeignClient.callFeignConsumer();
    }


}
